package adroid.kryten.util;

import java.util.List;

import android.content.Context;
import android.kryten.R;
import android.kryten.model.*;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class NewsAdapter extends ArrayAdapter<News> {

    /**
     * @param context
     * @param resource
     * @param textViewResourceId
     * @param objects
     */
    public NewsAdapter(Context context, List<News> objects) {
        super(context, 0, 0, objects);
    }

    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        News n = getItem(position);
        
        if (convertView == null)
            convertView = View.inflate(getContext(), R.layout.news_item, null);
        
        TextView tvAuthor = (TextView)convertView.findViewById(R.id.news_item_author);
        TextView tvNews = (TextView)convertView.findViewById(R.id.news_item_news);
                
        if (n != null) {
//            tvAuthor.setText(n.getAuthor());
        	tvNews.setText(n.getNews());
            
        }
        return convertView;
    }
    
    
    
}